import request from '@/utils/request'

export const getGoodsTypeData = (pageinfo) => {
  return request.get('goods/goodsType/getGoodsTypePage', {
    params: {
      pageSize: pageinfo.pageSize,
      pageNum: pageinfo.pageNum
    }
  })
}

export const getGoodsTypeList = () => {
  return request.get('goods/goodsType/getGoodsTypeList')
}

export const getParentGoodsTypeList = () => {
  return request.get('goods/goodsType/getParentGoodsTypeList')
}

export const addGoodsType = (addForm) => {
  return request.post('goods/goodsType/addGoodsType', {
    name: addForm.name,
    priority: addForm.priority,
    level: addForm.level,
    parentGoodsTypeId: addForm.parentId
  })
}

export const getGoodsTypeById = (id) => {
  return request.get('goods/goodsType/getGoodsTypeById', {
    params: {
      id
    }
  })
}

export const updateGoodsType = (updateForm) => {
  return request.post('goods/goodsType/updateGoodsType', updateForm)
}

export const deleteGoodsTypeById = (id) => {
  return request.delete('goods/goodsType/deleteGoodsTypeById?id=' + id)
}

export const clearGoodsTypeCache = () => {
  return request.post('goods/goodsType/clearGoodsTypeCache')
}

export const getTypeImgData = (id) => {
  return request.get('goods/goodsType/getGoodsTypePic', {
    params: {
      id
    }
  })
}

export const getWxTypeImgData = (id) => {
  return request.get('goods/goodsType/adminGetGoodsTypeWxPic', {
    params: {
      id
    }
  })
}

export const addPic = (obj) => {
  return request.post('goods/goodsType/addPic',
    obj
  )
}

export const addWxPic = (obj) => {
  return request.post('goods/goodsType/adminAddGoodsTypeWxPic',
    obj
  )
}
// export const uploadTypeImgDel = (url) => {
//   return request.post('goods/goodsType/uploadTypeImgDel', {
//     url
//   })
// }
